<template>
    <div class="jnpf-tree-wrapper" v-if='(preview&&menus.length>0)||!preview'>
        <ContextMenuCom :baseItems="menuContent"></ContextMenuCom>
        <div class="jnpf-menu">
            <div class="jnpf-menu-item" v-for="menu in menus" :key="menu.id" :class="{ active: menu.isActive }"
                @click="checkMenu(menu)" @contextmenu.stop.prevent='contexMenuEvent(menu)'>
                <el-tree-select v-if="!preview" v-model="menu.moduleId" :data="featureWebData" :props="{
            label: 'fullName',
            value: 'id'
        }" :render-after-expand="false" style="width: 100%" size="small"
        @click.stop=''
                    @current-change="(data, node) => handleChange(data, node, menu)" placeholder='请选择'/>
                <div v-else>
                    {{ menu.label }}
                </div>
                <span v-if="!preview" class="eye" title="是否显示数据树" @click.stop="menu.showTree = !menu.showTree">
                    <es-icon :name="menu.showTree ? 'show' : 'unshow'" :color="'rgba(255, 255, 255, 1)'" :size="18" />
                </span>
            </div>
            <div class="jnpf-menu-item" @click="addMenu()" v-if="!preview">
                <i class="el-icon-plus">添加菜单</i>
            </div>
            <!-- <div class="jnpf-menu-item" @click="thingsboard()" v-if="!preview">
                <i class="el-icon-plus">添加things</i>
            </div> -->
        </div>
    </div>

</template>

<script>
import { getConfig, getList, getFeatureSelector, getDictionaryDataSelector, getDepartmentSelector, getDataInterfaceRes } from '@/api/jnpf'
import ContextMenuCom from "@/components/commom/ContextMenuCom.vue";
// import ws from './websocket'
import {getCurrentInstance} from 'vue'
const instance= getCurrentInstance()
const bus = instance?.appContext.config.globalProperties.$bus
export default {
    components: {
        ContextMenuCom
    },
    props: {
        jnpfMenuData: {
            type: Array,
            default: []
        },
        xbsjEarthUi: {
            type: Object
        },
        preview: {
            type: Boolean,
            default: false,
        }
    },
    data() {
        return {
            menus: this.jnpfMenuData,
            activeMenu: [],
            moduleId: '',
            featureWebData: [],
            menuContent: [],
        }
    },
    watch: {
        jnpfMenuData: {
            handler: function () {
                this.menus = this.jnpfMenuData

            },
            deep: true,
        },
        menus: {
            handler: function () {
                this.$emit('updateMenuData', this.menus)
            },
            deep: true,
        },

    },
    created() {
        this.fetchFeatureList()
    },
    methods: {
        thingsboard() {
            let board = {
                "id": {
                    "entityType": "DASHBOARD",
                    "id": "21f249b0-051a-11ef-8638-29a8cf47863a"
                },
                "createdTime": 1714279526859,
                "tenantId": {
                    "entityType": "TENANT",
                    "id": "478cc590-fca7-11ee-885e-83ae50627ef1"
                },
                "title": "鼓风机_01",
                "image": null,
                "assignedCustomers": [
                    {
                        "customerId": {
                            "entityType": "CUSTOMER",
                            "id": "ed341f40-0b50-11ef-8638-29a8cf47863a"
                        },
                        "title": "Public",
                        "public": true
                    }
                ],
                "mobileHide": false,
                "mobileOrder": null,
                "configuration": {
                    "description": "",
                    "widgets": {
                        "6a105a9f-63cb-338f-b52b-bbf32aa06926": {
                            "typeFullFqn": "system.cards.entities_table",
                            "type": "latest",
                            "sizeX": 7.5,
                            "sizeY": 6.5,
                            "config": {
                                "timewindow": {
                                    "displayValue": "",
                                    "selectedTab": 0,
                                    "realtime": {
                                        "realtimeType": 1,
                                        "interval": 1000,
                                        "timewindowMs": 86400000,
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "history": {
                                        "historyType": 0,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "fixedTimewindow": {
                                            "startTimeMs": 1714193425035,
                                            "endTimeMs": 1714279825035
                                        },
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "aggregation": {
                                        "type": "NONE",
                                        "limit": 200
                                    }
                                },
                                "showTitle": true,
                                "backgroundColor": "rgb(255, 255, 255)",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "4px",
                                "settings": {
                                    "entitiesTitle": "设备列表",
                                    "enableSearch": true,
                                    "enableSelectColumnDisplay": true,
                                    "enableStickyHeader": true,
                                    "enableStickyAction": true,
                                    "showCellActionsMenu": true,
                                    "reserveSpaceForHiddenAction": "true",
                                    "displayEntityName": false,
                                    "entityNameColumnTitle": "",
                                    "displayEntityLabel": false,
                                    "entityLabelColumnTitle": "",
                                    "displayEntityType": false,
                                    "displayPagination": true,
                                    "defaultPageSize": 10,
                                    "defaultSortOrder": "name",
                                    "useRowStyleFunction": false,
                                    "rowStyleFunction": ""
                                },
                                "title": "设备列表",
                                "dropShadow": false,
                                "enableFullscreen": false,
                                "titleStyle": {
                                    "fontSize": "16px",
                                    "fontWeight": 400,
                                    "padding": "5px 10px 5px 10px"
                                },
                                "useDashboardTimewindow": false,
                                "showLegend": false,
                                "datasources": [
                                    {
                                        "type": "entity",
                                        "name": "",
                                        "deviceId": "48617ab0-fca7-11ee-885e-83ae50627ef1",
                                        "entityAliasId": "38aef70f-4d80-cfc6-7a1c-ad79edf5b9ab",
                                        "filterId": null,
                                        "dataKeys": [
                                            {
                                                "name": "name",
                                                "type": "entityField",
                                                "label": "名称",
                                                "color": "#2196f3",
                                                "settings": {},
                                                "_hash": 0.7620468700297145
                                            },
                                            {
                                                "name": "type",
                                                "type": "entityField",
                                                "label": "类型",
                                                "color": "#f44336",
                                                "settings": {},
                                                "_hash": 0.9369163427054119,
                                                "decimals": 0
                                            },
                                            {
                                                "name": "current",
                                                "type": "timeseries",
                                                "label": "电流",
                                                "color": "#ffc107",
                                                "settings": {},
                                                "_hash": 0.9377865352680047,
                                                "aggregationType": "NONE",
                                                "units": null,
                                                "decimals": null,
                                                "funcBody": null,
                                                "usePostProcessing": null,
                                                "postFuncBody": null
                                            },
                                            {
                                                "name": "active",
                                                "type": "attribute",
                                                "label": "状态",
                                                "color": "#ffc107",
                                                "settings": {},
                                                "_hash": 0.43312924244610884,
                                                "aggregationType": null,
                                                "units": null,
                                                "decimals": null,
                                                "funcBody": null,
                                                "usePostProcessing": null,
                                                "postFuncBody": null
                                            }
                                        ],
                                        "alarmFilterConfig": {
                                            "statusList": [
                                                "ACTIVE"
                                            ]
                                        }
                                    }
                                ],
                                "displayTimewindow": false,
                                "configMode": "advanced",
                                "actions": {
                                    "rowClick": [
                                        {
                                            "name": "查看数据详情",
                                            "icon": "more_horiz",
                                            "useShowWidgetActionFunction": null,
                                            "showWidgetActionFunction": "return true;",
                                            "type": "openDashboardState",
                                            "targetDashboardStateId": "current_details",
                                            "setEntityId": true,
                                            "stateEntityParamName": null,
                                            "openRightLayout": false,
                                            "openInSeparateDialog": false,
                                            "openInPopover": false,
                                            "id": "3a954449-27c5-9728-35f5-c2580a10c707"
                                        }
                                    ]
                                },
                                "showTitleIcon": false,
                                "titleIcon": "list",
                                "iconColor": null,
                                "titleFont": null,
                                "titleColor": null,
                                "titleTooltip": "",
                                "widgetStyle": {},
                                "widgetCss": "",
                                "pageSize": 1024,
                                "noDataDisplayMessage": "",
                                "margin": "",
                                "borderRadius": "4px"
                            },
                            "row": 0,
                            "col": 0,
                            "id": "6a105a9f-63cb-338f-b52b-bbf32aa06926"
                        },
                        "bd1c5dc8-f131-2fa6-ee9d-daa45bf3b81b": {
                            "typeFullFqn": "system.analogue_gauges.temperature_radial_gauge_canvas_gauges",
                            "type": "latest",
                            "sizeX": 6,
                            "sizeY": 5,
                            "config": {
                                "datasources": [
                                    {
                                        "type": "device",
                                        "name": "",
                                        "deviceId": "48617ab0-fca7-11ee-885e-83ae50627ef1",
                                        "dataKeys": [
                                            {
                                                "name": "current",
                                                "type": "timeseries",
                                                "label": "Temperature",
                                                "color": "#2196f3",
                                                "settings": {},
                                                "_hash": 0.27992613547597256,
                                                "aggregationType": "NONE",
                                                "units": null,
                                                "decimals": null,
                                                "funcBody": null,
                                                "usePostProcessing": null,
                                                "postFuncBody": null
                                            }
                                        ],
                                        "alarmFilterConfig": {
                                            "statusList": [
                                                "ACTIVE"
                                            ]
                                        }
                                    }
                                ],
                                "timewindow": {
                                    "displayValue": "",
                                    "selectedTab": 0,
                                    "realtime": {
                                        "realtimeType": 1,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "history": {
                                        "historyType": 0,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "fixedTimewindow": {
                                            "startTimeMs": 1714233168590,
                                            "endTimeMs": 1714319568590
                                        },
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "aggregation": {
                                        "type": "AVG",
                                        "limit": 25000
                                    }
                                },
                                "showTitle": false,
                                "backgroundColor": "rgb(255, 255, 255)",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "8px",
                                "settings": {
                                    "startAngle": 67.5,
                                    "ticksAngle": 225,
                                    "needleCircleSize": 7,
                                    "defaultColor": "#e65100",
                                    "minValue": 0,
                                    "maxValue": 60,
                                    "majorTicksCount": 12,
                                    "colorMajorTicks": "#444",
                                    "minorTicks": 12,
                                    "colorMinorTicks": "#666",
                                    "numbersFont": {
                                        "family": "Roboto",
                                        "size": 20,
                                        "style": "normal",
                                        "weight": "normal",
                                        "color": "#263238"
                                    },
                                    "numbersColor": "#263238",
                                    "showUnitTitle": true,
                                    "unitTitle": "电流",
                                    "titleFont": {
                                        "family": "Roboto",
                                        "size": 24,
                                        "style": "normal",
                                        "weight": "normal",
                                        "color": "#263238"
                                    },
                                    "titleColor": "#263238",
                                    "unitsFont": {
                                        "family": "Roboto",
                                        "size": 28,
                                        "style": "normal",
                                        "weight": "500",
                                        "color": "#616161"
                                    },
                                    "unitsColor": "#616161",
                                    "valueBox": true,
                                    "valueInt": 3,
                                    "valueFont": {
                                        "family": "Segment7Standard",
                                        "size": 30,
                                        "style": "normal",
                                        "weight": "normal",
                                        "shadowColor": "rgba(0, 0, 0, 0.49)",
                                        "color": "#444"
                                    },
                                    "valueColor": "#444",
                                    "valueColorShadow": "rgba(0, 0, 0, 0.49)",
                                    "colorValueBoxRect": "#888",
                                    "colorValueBoxRectEnd": "#666",
                                    "colorValueBoxBackground": "#babab2",
                                    "colorValueBoxShadow": "rgba(0,0,0,1)",
                                    "showBorder": true,
                                    "colorPlate": "#cfd8dc",
                                    "colorNeedle": null,
                                    "colorNeedleEnd": null,
                                    "colorNeedleShadowUp": "rgba(2, 255, 255, 0)",
                                    "colorNeedleShadowDown": "rgba(188, 143, 143, 0.78)",
                                    "highlightsWidth": 15,
                                    "highlights": [
                                        {
                                            "from": -60,
                                            "to": -50,
                                            "color": "#42a5f5"
                                        },
                                        {
                                            "from": -50,
                                            "to": -40,
                                            "color": "rgba(66, 165, 245, 0.83)"
                                        },
                                        {
                                            "from": -40,
                                            "to": -30,
                                            "color": "rgba(66, 165, 245, 0.66)"
                                        },
                                        {
                                            "from": -30,
                                            "to": -20,
                                            "color": "rgba(66, 165, 245, 0.5)"
                                        },
                                        {
                                            "from": -20,
                                            "to": -10,
                                            "color": "rgba(66, 165, 245, 0.33)"
                                        },
                                        {
                                            "from": -10,
                                            "to": 0,
                                            "color": "rgba(66, 165, 245, 0.16)"
                                        },
                                        {
                                            "from": 0,
                                            "to": 10,
                                            "color": "rgba(229, 115, 115, 0.16)"
                                        },
                                        {
                                            "from": 10,
                                            "to": 20,
                                            "color": "rgba(229, 115, 115, 0.33)"
                                        },
                                        {
                                            "from": 20,
                                            "to": 30,
                                            "color": "rgba(229, 115, 115, 0.5)"
                                        },
                                        {
                                            "from": 30,
                                            "to": 40,
                                            "color": "rgba(229, 115, 115, 0.66)"
                                        },
                                        {
                                            "from": 40,
                                            "to": 50,
                                            "color": "rgba(229, 115, 115, 0.83)"
                                        },
                                        {
                                            "from": 50,
                                            "to": 60,
                                            "color": "#e57373"
                                        }
                                    ],
                                    "animation": true,
                                    "animationDuration": 1000,
                                    "animationRule": "bounce"
                                },
                                "title": "Temperature radial gauge",
                                "dropShadow": false,
                                "enableFullscreen": false,
                                "titleStyle": {
                                    "fontSize": "16px",
                                    "fontWeight": 400
                                },
                                "widgetStyle": {},
                                "widgetCss": "",
                                "pageSize": 1024,
                                "decimals": 0,
                                "noDataDisplayMessage": "",
                                "configMode": "advanced",
                                "units": "安",
                                "useDashboardTimewindow": true,
                                "displayTimewindow": true,
                                "actions": {},
                                "borderRadius": null
                            },
                            "row": 0,
                            "col": 0,
                            "id": "bd1c5dc8-f131-2fa6-ee9d-daa45bf3b81b"
                        },
                        "9ca6aa90-677c-5ebe-39eb-d2530d546d3c": {
                            "typeFullFqn": "system.line_chart",
                            "type": "timeseries",
                            "sizeX": 8,
                            "sizeY": 5,
                            "config": {
                                "datasources": [
                                    {
                                        "type": "entity",
                                        "name": "",
                                        "deviceId": "48617ab0-fca7-11ee-885e-83ae50627ef1",
                                        "entityAliasId": "38aef70f-4d80-cfc6-7a1c-ad79edf5b9ab",
                                        "dataKeys": [
                                            {
                                                "name": "current",
                                                "type": "timeseries",
                                                "label": "电流",
                                                "color": "#2196f3",
                                                "settings": {
                                                    "yAxisId": "default",
                                                    "showInLegend": true,
                                                    "dataHiddenByDefault": false,
                                                    "type": "line",
                                                    "lineSettings": {
                                                        "showLine": true,
                                                        "step": false,
                                                        "stepType": "start",
                                                        "smooth": false,
                                                        "lineType": "solid",
                                                        "lineWidth": 2,
                                                        "showPoints": false,
                                                        "showPointLabel": false,
                                                        "pointLabelPosition": "top",
                                                        "pointLabelFont": {
                                                            "family": "Roboto",
                                                            "size": 11,
                                                            "sizeUnit": "px",
                                                            "style": "normal",
                                                            "weight": "400",
                                                            "lineHeight": "1"
                                                        },
                                                        "pointLabelColor": "rgba(0, 0, 0, 0.76)",
                                                        "pointShape": "emptyCircle",
                                                        "pointSize": 4,
                                                        "fillAreaSettings": {
                                                            "type": "none",
                                                            "opacity": 0.4,
                                                            "gradient": {
                                                                "start": 100,
                                                                "end": 0
                                                            }
                                                        }
                                                    },
                                                    "barSettings": {
                                                        "showBorder": false,
                                                        "borderWidth": 2,
                                                        "borderRadius": 0,
                                                        "showLabel": false,
                                                        "labelPosition": "top",
                                                        "labelFont": {
                                                            "family": "Roboto",
                                                            "size": 11,
                                                            "sizeUnit": "px",
                                                            "style": "normal",
                                                            "weight": "400",
                                                            "lineHeight": "1"
                                                        },
                                                        "labelColor": "rgba(0, 0, 0, 0.76)",
                                                        "backgroundSettings": {
                                                            "type": "none",
                                                            "opacity": 0.4,
                                                            "gradient": {
                                                                "start": 100,
                                                                "end": 0
                                                            }
                                                        }
                                                    }
                                                },
                                                "_hash": 0.4037648987353659,
                                                "units": "安",
                                                "decimals": 2,
                                                "aggregationType": null,
                                                "funcBody": null,
                                                "usePostProcessing": null,
                                                "postFuncBody": null
                                            }
                                        ],
                                        "alarmFilterConfig": {
                                            "statusList": [
                                                "ACTIVE"
                                            ]
                                        },
                                        "latestDataKeys": []
                                    }
                                ],
                                "timewindow": {
                                    "hideInterval": false,
                                    "hideLastInterval": false,
                                    "hideQuickInterval": false,
                                    "hideAggregation": false,
                                    "hideAggInterval": false,
                                    "hideTimezone": false,
                                    "selectedTab": 0,
                                    "realtime": {
                                        "realtimeType": 0,
                                        "timewindowMs": 60000,
                                        "quickInterval": "CURRENT_DAY",
                                        "interval": 1000
                                    },
                                    "aggregation": {
                                        "type": "AVG",
                                        "limit": 25000
                                    },
                                    "timezone": null
                                },
                                "showTitle": true,
                                "backgroundColor": "rgba(0, 0, 0, 0)",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "0px",
                                "settings": {
                                    "yAxes": {
                                        "default": {
                                            "units": null,
                                            "decimals": 0,
                                            "show": true,
                                            "label": "",
                                            "labelFont": {
                                                "family": "Roboto",
                                                "size": 12,
                                                "sizeUnit": "px",
                                                "style": "normal",
                                                "weight": "600",
                                                "lineHeight": "1"
                                            },
                                            "labelColor": "rgba(0, 0, 0, 0.54)",
                                            "position": "left",
                                            "showTickLabels": true,
                                            "tickLabelFont": {
                                                "family": "Roboto",
                                                "size": 12,
                                                "sizeUnit": "px",
                                                "style": "normal",
                                                "weight": "400",
                                                "lineHeight": "1"
                                            },
                                            "tickLabelColor": "rgba(0, 0, 0, 0.54)",
                                            "ticksFormatter": null,
                                            "showTicks": true,
                                            "ticksColor": "rgba(0, 0, 0, 0.54)",
                                            "showLine": true,
                                            "lineColor": "rgba(0, 0, 0, 0.54)",
                                            "showSplitLines": true,
                                            "splitLinesColor": "rgba(0, 0, 0, 0.12)",
                                            "id": "default",
                                            "order": 0
                                        }
                                    },
                                    "thresholds": [],
                                    "dataZoom": true,
                                    "stack": false,
                                    "xAxis": {
                                        "show": true,
                                        "label": "",
                                        "labelFont": {
                                            "family": "Roboto",
                                            "size": 12,
                                            "sizeUnit": "px",
                                            "style": "normal",
                                            "weight": "600",
                                            "lineHeight": "1"
                                        },
                                        "labelColor": "rgba(0, 0, 0, 0.54)",
                                        "position": "bottom",
                                        "showTickLabels": true,
                                        "tickLabelFont": {
                                            "family": "Roboto",
                                            "size": 10,
                                            "sizeUnit": "px",
                                            "style": "normal",
                                            "weight": "400",
                                            "lineHeight": "1"
                                        },
                                        "tickLabelColor": "rgba(0, 0, 0, 0.54)",
                                        "ticksFormat": {},
                                        "showTicks": true,
                                        "ticksColor": "rgba(0, 0, 0, 0.54)",
                                        "showLine": true,
                                        "lineColor": "rgba(0, 0, 0, 0.54)",
                                        "showSplitLines": true,
                                        "splitLinesColor": "rgba(0, 0, 0, 0.12)"
                                    },
                                    "noAggregationBarWidthSettings": {
                                        "strategy": "group",
                                        "groupWidth": {
                                            "relative": true,
                                            "relativeWidth": 2,
                                            "absoluteWidth": 1000
                                        },
                                        "barWidth": {
                                            "relative": true,
                                            "relativeWidth": 2,
                                            "absoluteWidth": 1000
                                        }
                                    },
                                    "showLegend": true,
                                    "legendLabelFont": {
                                        "family": "Roboto",
                                        "size": 12,
                                        "sizeUnit": "px",
                                        "style": "normal",
                                        "weight": "400",
                                        "lineHeight": "16px"
                                    },
                                    "legendLabelColor": "rgba(0, 0, 0, 0.76)",
                                    "legendConfig": {
                                        "direction": "column",
                                        "position": "top",
                                        "sortDataKeys": false,
                                        "showMin": false,
                                        "showMax": false,
                                        "showAvg": true,
                                        "showTotal": false,
                                        "showLatest": false
                                    },
                                    "showTooltip": true,
                                    "tooltipTrigger": "axis",
                                    "tooltipValueFont": {
                                        "family": "Roboto",
                                        "size": 12,
                                        "sizeUnit": "px",
                                        "style": "normal",
                                        "weight": "500",
                                        "lineHeight": "16px"
                                    },
                                    "tooltipValueColor": "rgba(0, 0, 0, 0.76)",
                                    "tooltipShowDate": true,
                                    "tooltipDateFormat": {
                                        "format": null,
                                        "lastUpdateAgo": false,
                                        "custom": false,
                                        "auto": true,
                                        "autoDateFormatSettings": {}
                                    },
                                    "tooltipDateFont": {
                                        "family": "Roboto",
                                        "size": 11,
                                        "sizeUnit": "px",
                                        "style": "normal",
                                        "weight": "400",
                                        "lineHeight": "16px"
                                    },
                                    "tooltipDateColor": "rgba(0, 0, 0, 0.76)",
                                    "tooltipDateInterval": true,
                                    "tooltipBackgroundColor": "rgba(255, 255, 255, 0.76)",
                                    "tooltipBackgroundBlur": 4,
                                    "animation": {
                                        "animation": true,
                                        "animationThreshold": 2000,
                                        "animationDuration": 500,
                                        "animationEasing": "cubicOut",
                                        "animationDelay": 0,
                                        "animationDurationUpdate": 300,
                                        "animationEasingUpdate": "cubicOut",
                                        "animationDelayUpdate": 0
                                    },
                                    "background": {
                                        "type": "color",
                                        "color": "#fff",
                                        "overlay": {
                                            "enabled": false,
                                            "color": "rgba(255,255,255,0.72)",
                                            "blur": 3
                                        }
                                    },
                                    "padding": "12px"
                                },
                                "title": "实时电流",
                                "dropShadow": false,
                                "enableFullscreen": true,
                                "titleStyle": null,
                                "configMode": "advanced",
                                "actions": {},
                                "showTitleIcon": false,
                                "titleIcon": "thermostat",
                                "iconColor": "#1F6BDD",
                                "useDashboardTimewindow": false,
                                "displayTimewindow": true,
                                "titleFont": {
                                    "size": 16,
                                    "sizeUnit": "px",
                                    "family": "Roboto",
                                    "weight": "500",
                                    "style": "normal",
                                    "lineHeight": "24px"
                                },
                                "titleColor": "rgba(0, 0, 0, 0.87)",
                                "titleTooltip": "",
                                "widgetStyle": {},
                                "widgetCss": "",
                                "pageSize": 1024,
                                "units": "",
                                "decimals": null,
                                "noDataDisplayMessage": "",
                                "timewindowStyle": {
                                    "showIcon": false,
                                    "iconSize": "24px",
                                    "icon": null,
                                    "iconPosition": "left",
                                    "font": {
                                        "size": 12,
                                        "sizeUnit": "px",
                                        "family": "Roboto",
                                        "weight": "400",
                                        "style": "normal",
                                        "lineHeight": "16px"
                                    },
                                    "color": "rgba(0, 0, 0, 0.38)",
                                    "displayTypePrefix": true
                                },
                                "margin": "0px",
                                "borderRadius": "0px",
                                "iconSize": "0px"
                            },
                            "row": 0,
                            "col": 0,
                            "id": "9ca6aa90-677c-5ebe-39eb-d2530d546d3c"
                        },
                        "188cc3e9-0f3c-9b3f-4d10-9d15a5294726": {
                            "typeFullFqn": "system.alarm_widgets.alarms_table",
                            "type": "alarm",
                            "sizeX": 10.5,
                            "sizeY": 6.5,
                            "config": {
                                "timewindow": {
                                    "realtime": {
                                        "interval": 1000,
                                        "timewindowMs": 86400000
                                    },
                                    "aggregation": {
                                        "type": "NONE",
                                        "limit": 200
                                    }
                                },
                                "showTitle": true,
                                "backgroundColor": "rgb(255, 255, 255)",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "4px",
                                "settings": {
                                    "enableSelection": true,
                                    "enableSearch": true,
                                    "displayDetails": true,
                                    "allowAcknowledgment": true,
                                    "allowClear": true,
                                    "allowAssign": true,
                                    "displayActivity": true,
                                    "displayPagination": true,
                                    "defaultPageSize": 10,
                                    "defaultSortOrder": "-createdTime",
                                    "enableSelectColumnDisplay": true,
                                    "enableStickyAction": false,
                                    "enableFilter": true,
                                    "entitiesTitle": null,
                                    "alarmsTitle": "报警信息"
                                },
                                "title": "Alarms table",
                                "dropShadow": false,
                                "enableFullscreen": false,
                                "titleStyle": {
                                    "fontSize": "16px",
                                    "fontWeight": 400,
                                    "padding": "5px 10px 5px 10px"
                                },
                                "useDashboardTimewindow": false,
                                "showLegend": false,
                                "alarmSource": {
                                    "type": "device",
                                    "name": "",
                                    "deviceId": "48617ab0-fca7-11ee-885e-83ae50627ef1",
                                    "entityAliasId": null,
                                    "dataKeys": [
                                        {
                                            "name": "createdTime",
                                            "type": "alarm",
                                            "label": "报警时间",
                                            "color": "#2196f3",
                                            "settings": {
                                                "useCellStyleFunction": false,
                                                "cellStyleFunction": "",
                                                "useCellContentFunction": false,
                                                "cellContentFunction": ""
                                            },
                                            "_hash": 0.021092237451093787,
                                            "funcBody": null
                                        },
                                        {
                                            "name": "originator",
                                            "type": "alarm",
                                            "label": "来源",
                                            "color": "#4caf50",
                                            "settings": {
                                                "useCellStyleFunction": false,
                                                "cellStyleFunction": "",
                                                "useCellContentFunction": false,
                                                "cellContentFunction": ""
                                            },
                                            "_hash": 0.2780007688856758,
                                            "funcBody": null
                                        },
                                        {
                                            "name": "type",
                                            "type": "alarm",
                                            "label": "类型",
                                            "color": "#f44336",
                                            "settings": {
                                                "useCellStyleFunction": false,
                                                "cellStyleFunction": "",
                                                "useCellContentFunction": false,
                                                "cellContentFunction": ""
                                            },
                                            "_hash": 0.7323586880398418,
                                            "funcBody": null
                                        },
                                        {
                                            "name": "severity",
                                            "type": "alarm",
                                            "label": "严重性",
                                            "color": "#ffc107",
                                            "settings": {
                                                "useCellStyleFunction": false,
                                                "useCellContentFunction": false
                                            },
                                            "_hash": 0.09927019860088193,
                                            "funcBody": null
                                        },
                                        {
                                            "name": "status",
                                            "type": "alarm",
                                            "label": "状态",
                                            "color": "#607d8b",
                                            "settings": {
                                                "useCellStyleFunction": false,
                                                "cellStyleFunction": "",
                                                "useCellContentFunction": false,
                                                "cellContentFunction": ""
                                            },
                                            "_hash": 0.6588418951443418,
                                            "funcBody": null
                                        }
                                    ],
                                    "alarmFilterConfig": {
                                        "statusList": [
                                            "ACTIVE"
                                        ]
                                    }
                                },
                                "alarmsPollingInterval": 5,
                                "showTitleIcon": false,
                                "titleIcon": "warning",
                                "iconColor": "rgba(0, 0, 0, 0.87)",
                                "iconSize": "24px",
                                "titleTooltip": "",
                                "widgetStyle": {},
                                "displayTimewindow": true,
                                "actions": {},
                                "configMode": "advanced",
                                "alarmFilterConfig": {
                                    "statusList": [],
                                    "severityList": [
                                        "CRITICAL",
                                        "MAJOR",
                                        "MINOR",
                                        "WARNING",
                                        "INDETERMINATE"
                                    ],
                                    "typeList": [],
                                    "searchPropagatedAlarms": false,
                                    "assignedToCurrentUser": false,
                                    "assigneeId": null
                                },
                                "datasources": [],
                                "titleFont": null,
                                "titleColor": null,
                                "widgetCss": "",
                                "pageSize": 1024,
                                "noDataDisplayMessage": ""
                            },
                            "row": 0,
                            "col": 0,
                            "id": "188cc3e9-0f3c-9b3f-4d10-9d15a5294726"
                        },
                        "01ae985f-4faa-d547-c1ba-e97916755d8f": {
                            "typeFullFqn": "system.maps_v2.google_maps",
                            "type": "latest",
                            "sizeX": 8.5,
                            "sizeY": 6,
                            "config": {
                                "datasources": [
                                    {
                                        "type": "entity",
                                        "name": "",
                                        "deviceId": "48617ab0-fca7-11ee-885e-83ae50627ef1",
                                        "entityAliasId": "38aef70f-4d80-cfc6-7a1c-ad79edf5b9ab",
                                        "filterId": null,
                                        "dataKeys": [
                                            {
                                                "name": "name",
                                                "type": "entityField",
                                                "label": "名称",
                                                "color": "#2196f3",
                                                "settings": {},
                                                "_hash": 0.11711606503648964
                                            },
                                            {
                                                "name": "current",
                                                "type": "timeseries",
                                                "label": "current",
                                                "color": "#4caf50",
                                                "settings": {},
                                                "_hash": 0.601207964231021
                                            },
                                            {
                                                "name": "latitude",
                                                "type": "attribute",
                                                "label": "latitude",
                                                "color": "#f44336",
                                                "settings": {},
                                                "_hash": 0.7252567309847991
                                            },
                                            {
                                                "name": "longitude",
                                                "type": "attribute",
                                                "label": "longitude",
                                                "color": "#ffc107",
                                                "settings": {},
                                                "_hash": 0.18662647876887617
                                            },
                                            {
                                                "name": "type",
                                                "type": "entityField",
                                                "label": "类型",
                                                "color": "#607d8b",
                                                "settings": {},
                                                "_hash": 0.05278671308244953
                                            }
                                        ],
                                        "alarmFilterConfig": {
                                            "statusList": [
                                                "ACTIVE"
                                            ]
                                        }
                                    }
                                ],
                                "timewindow": {
                                    "displayValue": "",
                                    "selectedTab": 0,
                                    "realtime": {
                                        "realtimeType": 1,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "history": {
                                        "historyType": 0,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "fixedTimewindow": {
                                            "startTimeMs": 1714233929951,
                                            "endTimeMs": 1714320329951
                                        },
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "aggregation": {
                                        "type": "AVG",
                                        "limit": 25000
                                    }
                                },
                                "showTitle": true,
                                "backgroundColor": "#fff",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "8px",
                                "settings": {
                                    "provider": "tencent-map",
                                    "tmApiKey": "84d6d83e0e51e481e50454ccbe8986b",
                                    "tmDefaultMapType": "roadmap",
                                    "latKeyName": "latitude",
                                    "lngKeyName": "longitude",
                                    "xPosKeyName": "xPos",
                                    "yPosKeyName": "yPos",
                                    "defaultZoomLevel": 10,
                                    "defaultCenterPosition": "0,0",
                                    "disableScrollZooming": false,
                                    "disableDoubleClickZooming": false,
                                    "disableZoomControl": false,
                                    "fitMapBounds": false,
                                    "useDefaultCenterPosition": false,
                                    "mapPageSize": 16384,
                                    "markerOffsetX": 0.5,
                                    "markerOffsetY": 1,
                                    "posFunction": "return {x: origXPos, y: origYPos};",
                                    "draggableMarker": false,
                                    "showLabel": true,
                                    "useLabelFunction": false,
                                    "label": "${entityName}",
                                    "labelFunction": null,
                                    "showTooltip": true,
                                    "showTooltipAction": "click",
                                    "autocloseTooltip": true,
                                    "useTooltipFunction": false,
                                    "tooltipPattern": "<b>${entityName}</b><br/><br/><b>经度:</b> ${latitude:7}<br/><b>纬度:</b> ${longitude:7}<br/><b>电流:</b> ${current} °C<br/><small>查看更多信息</small>",
                                    "tooltipFunction": null,
                                    "tooltipOffsetX": 0,
                                    "tooltipOffsetY": -1,
                                    "color": "#81C4E9",
                                    "useColorFunction": false,
                                    "colorFunction": null,
                                    "useMarkerImageFunction": true,
                                    "markerImage": null,
                                    "markerImageSize": 34,
                                    "markerImageFunction": "var type = dsData[dsIndex]['Type'];\nif (type == 'thermometer') {\n\tvar res = {\n\t    url: images[0],\n\t    size: 40\n\t}\n\tvar temperature = dsData[dsIndex]['temperature'];\n\tif (typeof temperature !== undefined) {\n\t    var percent = (temperature + 60)/120;\n\t    var index = Math.min(3, Math.floor(4 * percent));\n\t    res.url = images[index];\n\t}\n\treturn res;\n}",
                                    "markerImages": [
                                        "tb-image;/api/images/system/map_marker_image_0_(1).png",
                                        "tb-image;/api/images/system/map_marker_image_1_(1).png",
                                        "tb-image;/api/images/system/map_marker_image_2_(1).png",
                                        "tb-image;/api/images/system/map_marker_image_3.png"
                                    ],
                                    "showPolygon": false,
                                    "polygonKeyName": "perimeter",
                                    "editablePolygon": false,
                                    "showPolygonLabel": false,
                                    "usePolygonLabelFunction": false,
                                    "polygonLabel": "${entityName}",
                                    "polygonLabelFunction": null,
                                    "showPolygonTooltip": false,
                                    "showPolygonTooltipAction": "click",
                                    "autoClosePolygonTooltip": true,
                                    "usePolygonTooltipFunction": false,
                                    "polygonTooltipPattern": "<b>${entityName}</b><br/><br/><b>TimeStamp:</b> ${ts:7}",
                                    "polygonTooltipFunction": null,
                                    "polygonColor": "#3388ff",
                                    "polygonOpacity": 0.2,
                                    "usePolygonColorFunction": false,
                                    "polygonColorFunction": null,
                                    "polygonStrokeColor": "#3388ff",
                                    "polygonStrokeOpacity": 1,
                                    "polygonStrokeWeight": 3,
                                    "usePolygonStrokeColorFunction": false,
                                    "polygonStrokeColorFunction": null,
                                    "showCircle": false,
                                    "circleKeyName": "perimeter",
                                    "editableCircle": false,
                                    "showCircleLabel": false,
                                    "useCircleLabelFunction": false,
                                    "circleLabel": "${entityName}",
                                    "circleLabelFunction": null,
                                    "showCircleTooltip": false,
                                    "showCircleTooltipAction": "click",
                                    "autoCloseCircleTooltip": true,
                                    "useCircleTooltipFunction": false,
                                    "circleTooltipPattern": "<b>${entityName}</b><br/><br/><b>TimeStamp:</b> ${ts:7}",
                                    "circleTooltipFunction": null,
                                    "circleFillColor": "#3388ff",
                                    "circleFillColorOpacity": 0.2,
                                    "useCircleFillColorFunction": false,
                                    "circleFillColorFunction": null,
                                    "circleStrokeColor": "#3388ff",
                                    "circleStrokeOpacity": 1,
                                    "circleStrokeWeight": 3,
                                    "useCircleStrokeColorFunction": false,
                                    "circleStrokeColorFunction": null,
                                    "useClusterMarkers": false,
                                    "zoomOnClick": true,
                                    "maxZoom": null,
                                    "maxClusterRadius": 80,
                                    "animate": true,
                                    "spiderfyOnMaxZoom": false,
                                    "showCoverageOnHover": true,
                                    "chunkedLoading": false,
                                    "removeOutsideVisibleBounds": true,
                                    "useIconCreateFunction": false,
                                    "clusterMarkerFunction": null
                                },
                                "title": "设备总览",
                                "dropShadow": false,
                                "enableFullscreen": true,
                                "titleStyle": {
                                    "fontSize": "16px",
                                    "fontWeight": 400
                                },
                                "useDashboardTimewindow": true,
                                "showLegend": false,
                                "widgetStyle": {},
                                "actions": {},
                                "displayTimewindow": true,
                                "showTitleIcon": false,
                                "titleTooltip": "",
                                "widgetCss": "",
                                "pageSize": 1024,
                                "noDataDisplayMessage": "",
                                "borderRadius": "4px"
                            },
                            "row": 0,
                            "col": 0,
                            "id": "01ae985f-4faa-d547-c1ba-e97916755d8f"
                        },
                        "2fab37b5-a7b8-a235-2942-63911512be03": {
                            "typeFullFqn": "system.entity_admin_widgets.device_admin_table",
                            "type": "latest",
                            "sizeX": 7.5,
                            "sizeY": 6.5,
                            "config": {
                                "timewindow": {
                                    "displayValue": "",
                                    "selectedTab": 0,
                                    "realtime": {
                                        "realtimeType": 1,
                                        "interval": 1000,
                                        "timewindowMs": 86400000,
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "history": {
                                        "historyType": 0,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "fixedTimewindow": {
                                            "startTimeMs": 1714234447997,
                                            "endTimeMs": 1714320847997
                                        },
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "aggregation": {
                                        "type": "NONE",
                                        "limit": 200
                                    }
                                },
                                "showTitle": true,
                                "backgroundColor": "rgb(255, 255, 255)",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "4px",
                                "settings": {
                                    "entitiesTitle": "编辑设备信息",
                                    "enableSearch": true,
                                    "enableSelectColumnDisplay": true,
                                    "enableStickyHeader": true,
                                    "enableStickyAction": true,
                                    "showCellActionsMenu": true,
                                    "reserveSpaceForHiddenAction": "true",
                                    "displayEntityName": false,
                                    "entityNameColumnTitle": "",
                                    "displayEntityLabel": false,
                                    "entityLabelColumnTitle": "",
                                    "displayEntityType": false,
                                    "displayPagination": true,
                                    "defaultPageSize": 10,
                                    "defaultSortOrder": "entityName",
                                    "useRowStyleFunction": false,
                                    "rowStyleFunction": ""
                                },
                                "title": "Device admin table",
                                "dropShadow": false,
                                "enableFullscreen": false,
                                "titleStyle": {
                                    "fontSize": "16px",
                                    "fontWeight": 400,
                                    "padding": "5px 10px 5px 10px"
                                },
                                "useDashboardTimewindow": false,
                                "showLegend": false,
                                "datasources": [
                                    {
                                        "type": "entity",
                                        "name": "",
                                        "deviceId": "48617ab0-fca7-11ee-885e-83ae50627ef1",
                                        "entityAliasId": "38aef70f-4d80-cfc6-7a1c-ad79edf5b9ab",
                                        "dataKeys": [
                                            {
                                                "name": "name",
                                                "type": "entityField",
                                                "label": "名称",
                                                "color": "#2196f3",
                                                "settings": {},
                                                "_hash": 0.9810508092132015
                                            },
                                            {
                                                "name": "latitude",
                                                "type": "attribute",
                                                "label": "latitude",
                                                "color": "#4caf50",
                                                "settings": {},
                                                "_hash": 0.36316777430057967,
                                                "decimals": 0
                                            },
                                            {
                                                "name": "longitude",
                                                "type": "attribute",
                                                "label": "longitude",
                                                "color": "#f44336",
                                                "settings": {},
                                                "_hash": 0.23954777661142712,
                                                "decimals": 0
                                            }
                                        ],
                                        "alarmFilterConfig": {
                                            "statusList": [
                                                "ACTIVE"
                                            ]
                                        }
                                    }
                                ],
                                "showTitleIcon": false,
                                "titleIcon": "more_horiz",
                                "iconColor": "rgba(0, 0, 0, 0.87)",
                                "iconSize": "24px",
                                "titleTooltip": "",
                                "widgetStyle": {},
                                "displayTimewindow": true,
                                "actions": {
                                    "headerButton": [
                                        {
                                            "name": "Add device",
                                            "icon": "add",
                                            "type": "customPretty",
                                            "customHtml": "<form #addDeviceForm=\"ngForm\" [formGroup]=\"addDeviceFormGroup\"\n      (ngSubmit)=\"save()\" style=\"width: 480px;\">\n  <mat-toolbar fxLayout=\"row\" color=\"primary\">\n    <h2>Add device</h2>\n    <span fxFlex></span>\n    <button mat-icon-button\n            (click)=\"cancel()\"\n            type=\"button\">\n      <mat-icon class=\"material-icons\">close</mat-icon>\n    </button>\n  </mat-toolbar>\n  <mat-progress-bar color=\"warn\" mode=\"indeterminate\" *ngIf=\"isLoading$ | async\">\n  </mat-progress-bar>\n  <div style=\"height: 4px;\" *ngIf=\"!(isLoading$ | async)\"></div>\n  <div mat-dialog-content>\n      <div class=\"mat-padding\" fxLayout=\"column\">\n            <mat-form-field class=\"mat-block\">\n                <mat-label>Device name</mat-label>\n                <input matInput formControlName=\"deviceName\" required>\n                <mat-error *ngIf=\"addDeviceFormGroup.get('deviceName').hasError('required')\">\n                    Device name is required.\n                </mat-error>\n            </mat-form-field>\n            <div fxLayout=\"row\" fxLayoutGap=\"8px\">\n                <tb-entity-subtype-autocomplete\n                    fxFlex=\"50\"\n                    formControlName=\"deviceType\"\n                    [required]=\"true\"\n                    [entityType]=\"'DEVICE'\"\n                ></tb-entity-subtype-autocomplete>\n                <mat-form-field fxFlex=\"50\" class=\"mat-block\">\n                    <mat-label>Label</mat-label>\n                    <input matInput formControlName=\"deviceLabel\">\n                </mat-form-field>\n            </div>\n            <div formGroupName=\"attributes\" fxLayout=\"row\" fxLayoutGap=\"8px\">\n                <mat-form-field fxFlex=\"50\" class=\"mat-block\">\n                    <mat-label>Latitude</mat-label>\n                    <input type=\"number\" step=\"any\" matInput formControlName=\"latitude\">\n                </mat-form-field>\n                <mat-form-field fxFlex=\"50\" class=\"mat-block\">\n                    <mat-label>Longitude</mat-label>\n                    <input type=\"number\" step=\"any\" matInput formControlName=\"longitude\">\n                </mat-form-field>\n            </div>\n      </div>  \n  </div>\n  <div mat-dialog-actions fxLayout=\"row\">\n    <span fxFlex></span>\n    <button mat-button color=\"primary\"\n            type=\"button\"\n            [disabled]=\"(isLoading$ | async)\"\n            (click)=\"cancel()\" cdkFocusInitial>\n      Cancel\n    </button>\n    <button mat-button mat-raised-button color=\"primary\"\n            style=\"margin-right: 20px;\"\n            type=\"submit\"\n            [disabled]=\"(isLoading$ | async) || addDeviceForm.invalid || !addDeviceForm.dirty\">\n      Create\n    </button>\n  </div>\n</form>\n",
                                            "customCss": "",
                                            "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\n\nopenAddDeviceDialog();\n\nfunction openAddDeviceDialog() {\n    customDialog.customDialog(htmlTemplate, AddDeviceDialogController).subscribe();\n}\n\nfunction AddDeviceDialogController(instance) {\n    let vm = instance;\n    \n    vm.addDeviceFormGroup = vm.fb.group({\n      deviceName: ['', [vm.validators.required]],\n      deviceType: ['', [vm.validators.required]],\n      deviceLabel: [''],\n      attributes: vm.fb.group({\n          latitude: [null],\n          longitude: [null]\n      })      \n    });\n    \n    vm.cancel = function() {\n        vm.dialogRef.close(null);\n    };\n    \n    vm.save = function() {\n        vm.addDeviceFormGroup.markAsPristine();\n        let device = {\n            name: vm.addDeviceFormGroup.get('deviceName').value,\n            type: vm.addDeviceFormGroup.get('deviceType').value,\n            label: vm.addDeviceFormGroup.get('deviceLabel').value\n        };\n        deviceService.saveDevice(device).subscribe(\n            function (device) {\n                saveAttributes(device.id).subscribe(\n                    function () {\n                        widgetContext.updateAliases();\n                        vm.dialogRef.close(null);\n                    }\n                );\n            }\n        );\n    };\n    \n    function saveAttributes(entityId) {\n        let attributes = vm.addDeviceFormGroup.get('attributes').value;\n        let attributesArray = [];\n        for (let key in attributes) {\n            attributesArray.push({key: key, value: attributes[key]});\n        }\n        if (attributesArray.length > 0) {\n            return attributeService.saveEntityAttributes(entityId, \"SERVER_SCOPE\", attributesArray);\n        } else {\n            return widgetContext.rxjs.of([]);\n        }\n    }\n}",
                                            "customResources": [],
                                            "id": "70837a9d-c3de-a9a7-03c5-dccd14998758"
                                        }
                                    ],
                                    "actionCellButton": [
                                        {
                                            "name": "Edit device",
                                            "icon": "edit",
                                            "useShowWidgetActionFunction": null,
                                            "showWidgetActionFunction": "return true;",
                                            "type": "customPretty",
                                            "customHtml": "<form #editDeviceForm=\"ngForm\" [formGroup]=\"editDeviceFormGroup\"\n      (ngSubmit)=\"save()\" style=\"width: 480px;\">\n  <mat-toolbar fxLayout=\"row\" color=\"primary\">\n    <h2>Edit device</h2>\n    <span fxFlex></span>\n    <button mat-icon-button\n            (click)=\"cancel()\"\n            type=\"button\">\n      <mat-icon class=\"material-icons\">close</mat-icon>\n    </button>\n  </mat-toolbar>\n  <mat-progress-bar color=\"warn\" mode=\"indeterminate\" *ngIf=\"isLoading$ | async\">\n  </mat-progress-bar>\n  <div style=\"height: 4px;\" *ngIf=\"!(isLoading$ | async)\"></div>\n  <div mat-dialog-content>\n      <div class=\"mat-padding\" fxLayout=\"column\">\n            <mat-form-field class=\"mat-block\">\n                <mat-label>Device name</mat-label>\n                <input matInput formControlName=\"deviceName\" required>\n                <mat-error *ngIf=\"editDeviceFormGroup.get('deviceName').hasError('required')\">\n                    Device name is required.\n                </mat-error>\n            </mat-form-field>\n            <div fxLayout=\"row\" fxLayoutGap=\"8px\">\n                <tb-entity-subtype-autocomplete\n                    fxFlex=\"50\"\n                    formControlName=\"deviceType\"\n                    [required]=\"true\"\n                    [entityType]=\"'DEVICE'\"\n                ></tb-entity-subtype-autocomplete>\n                <mat-form-field fxFlex=\"50\" class=\"mat-block\">\n                    <mat-label>Label</mat-label>\n                    <input matInput formControlName=\"deviceLabel\">\n                </mat-form-field>\n            </div>\n            <div formGroupName=\"attributes\" fxLayout=\"row\" fxLayoutGap=\"8px\">\n                <mat-form-field fxFlex=\"50\" class=\"mat-block\">\n                    <mat-label>Latitude</mat-label>\n                    <input type=\"number\" step=\"any\" matInput formControlName=\"latitude\">\n                </mat-form-field>\n                <mat-form-field fxFlex=\"50\" class=\"mat-block\">\n                    <mat-label>Longitude</mat-label>\n                    <input type=\"number\" step=\"any\" matInput formControlName=\"longitude\">\n                </mat-form-field>\n            </div>\n      </div>  \n  </div>\n  <div mat-dialog-actions fxLayout=\"row\">\n    <span fxFlex></span>\n    <button mat-button color=\"primary\"\n            type=\"button\"\n            [disabled]=\"(isLoading$ | async)\"\n            (click)=\"cancel()\" cdkFocusInitial>\n      Cancel\n    </button>\n    <button mat-button mat-raised-button color=\"primary\"\n            style=\"margin-right: 20px;\"\n            type=\"submit\"\n            [disabled]=\"(isLoading$ | async) || editDeviceForm.invalid || !editDeviceForm.dirty\">\n      Update\n    </button>\n  </div>\n</form>\n",
                                            "customCss": "",
                                            "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\n\nopenEditDeviceDialog();\n\nfunction openEditDeviceDialog() {\n    customDialog.customDialog(htmlTemplate, EditDeviceDialogController).subscribe();\n}\n\nfunction EditDeviceDialogController(instance) {\n    let vm = instance;\n    \n    vm.device = null;\n    vm.attributes = {};\n    \n    vm.editDeviceFormGroup = vm.fb.group({\n      deviceName: ['', [vm.validators.required]],\n      deviceType: ['', [vm.validators.required]],\n      deviceLabel: [''],\n      attributes: vm.fb.group({\n          latitude: [null],\n          longitude: [null]\n      })      \n    });\n    \n    vm.cancel = function() {\n        vm.dialogRef.close(null);\n    };\n    \n    vm.save = function() {\n        vm.editDeviceFormGroup.markAsPristine();\n        if (vm.editDeviceFormGroup.get('deviceType').value !== vm.device.type) {\n            delete vm.device.deviceProfileId;\n        }\n        vm.device.name = vm.editDeviceFormGroup.get('deviceName').value,\n        vm.device.type = vm.editDeviceFormGroup.get('deviceType').value,\n        vm.device.label = vm.editDeviceFormGroup.get('deviceLabel').value\n        deviceService.saveDevice(vm.device).subscribe(\n            function () {\n                saveAttributes().subscribe(\n                    function () {\n                        widgetContext.updateAliases();\n                        vm.dialogRef.close(null);\n                    }\n                );\n            }\n        );\n    };\n    \n    getEntityInfo();\n    \n    function getEntityInfo() {\n        deviceService.getDevice(entityId.id).subscribe(\n            function (device) {\n                attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE',\n                                                    ['latitude', 'longitude']).subscribe(\n                   function (attributes) {\n                        for (let i = 0; i < attributes.length; i++) {\n                            vm.attributes[attributes[i].key] = attributes[i].value; \n                        }\n                        vm.device = device;\n                        vm.editDeviceFormGroup.patchValue(\n                            {\n                                deviceName: vm.device.name,\n                                deviceType: vm.device.type,\n                                deviceLabel: vm.device.label,\n                                attributes: {\n                                    latitude: vm.attributes.latitude,\n                                    longitude: vm.attributes.longitude\n                                }\n                            }, {emitEvent: false}\n                        );\n                   } \n                );\n            }\n        );    \n    }\n    \n    function saveAttributes() {\n        let attributes = vm.editDeviceFormGroup.get('attributes').value;\n        let attributesArray = [];\n        for (let key in attributes) {\n            attributesArray.push({key: key, value: attributes[key]});\n        }\n        if (attributesArray.length > 0) {\n            return attributeService.saveEntityAttributes(entityId, 'SERVER_SCOPE', attributesArray);\n        } else {\n            return widgetContext.rxjs.of([]);\n        }\n    }\n}",
                                            "customResources": [],
                                            "openInSeparateDialog": false,
                                            "openInPopover": false,
                                            "id": "93931e52-5d7c-903e-67aa-b9435df44ff4"
                                        },
                                        {
                                            "name": "Delete device",
                                            "icon": "delete",
                                            "type": "custom",
                                            "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet dialogs = $injector.get(widgetContext.servicesMap.get('dialogs'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenDeleteDeviceDialog();\n\nfunction openDeleteDeviceDialog() {\n    let title = \"Are you sure you want to delete the device \" + entityName +  \"?\";\n    let content = \"Be careful, after the confirmation, the device and all related data will become unrecoverable!\";\n    dialogs.confirm(title, content, 'Cancel', 'Delete').subscribe(\n        function (result) {\n            if (result) {\n                deleteDevice();\n            }\n        }\n    );\n}\n\nfunction deleteDevice() {\n    deviceService.deleteDevice(entityId.id).subscribe(\n        function () {\n            widgetContext.updateAliases();\n        }\n    );\n}\n",
                                            "id": "ec2708f6-9ff0-186b-e4fc-7635ebfa3074"
                                        }
                                    ]
                                },
                                "configMode": "advanced",
                                "titleFont": null,
                                "titleColor": null,
                                "widgetCss": "",
                                "pageSize": 1024,
                                "noDataDisplayMessage": ""
                            },
                            "row": 0,
                            "col": 0,
                            "id": "2fab37b5-a7b8-a235-2942-63911512be03"
                        },
                        "cfad97c0-7046-a32d-0847-c5e80d8a8193": {
                            "typeFullFqn": "system.alarm_count",
                            "type": "latest",
                            "sizeX": 3.5,
                            "sizeY": 1.5,
                            "config": {
                                "datasources": [
                                    {
                                        "type": "alarmCount",
                                        "name": "设备总数",
                                        "dataKeys": [
                                            {
                                                "name": "count",
                                                "type": "count",
                                                "label": "count",
                                                "settings": {},
                                                "_hash": 0.4556850358909543
                                            }
                                        ],
                                        "alarmFilterConfig": {
                                            "statusList": [
                                                "ACTIVE",
                                                "CLEARED"
                                            ],
                                            "severityList": [
                                                "CRITICAL",
                                                "MAJOR"
                                            ],
                                            "assignedToCurrentUser": false,
                                            "assigneeId": null
                                        }
                                    }
                                ],
                                "timewindow": {
                                    "displayValue": "",
                                    "selectedTab": 0,
                                    "realtime": {
                                        "realtimeType": 1,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "history": {
                                        "historyType": 0,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "fixedTimewindow": {
                                            "startTimeMs": 1714270340107,
                                            "endTimeMs": 1714356740107
                                        },
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "aggregation": {
                                        "type": "AVG",
                                        "limit": 25000
                                    }
                                },
                                "showTitle": false,
                                "backgroundColor": "rgb(255, 255, 255)",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "0px",
                                "settings": {
                                    "layout": "column",
                                    "autoScale": true,
                                    "showLabel": true,
                                    "label": "告警总数",
                                    "labelFont": {
                                        "family": "Roboto",
                                        "size": 10,
                                        "sizeUnit": "px",
                                        "style": "normal",
                                        "weight": "400",
                                        "lineHeight": "16px"
                                    },
                                    "labelColor": {
                                        "type": "constant",
                                        "color": "rgba(0, 0, 0, 0.54)",
                                        "colorFunction": "var temperature = value;\nif (typeof temperature !== undefined) {\n  var percent = (temperature + 60)/120 * 100;\n  return tinycolor.mix('blue', 'red', percent).toHexString();\n}\nreturn 'blue';"
                                    },
                                    "showIcon": true,
                                    "iconSize": 20,
                                    "iconSizeUnit": "px",
                                    "icon": "warning",
                                    "iconColor": {
                                        "type": "constant",
                                        "color": "rgba(255, 255, 255, 1)",
                                        "colorFunction": "var temperature = value;\nif (typeof temperature !== undefined) {\n  var percent = (temperature + 60)/120 * 100;\n  return tinycolor.mix('blue', 'red', percent).toHexString();\n}\nreturn 'blue';"
                                    },
                                    "showIconBackground": true,
                                    "iconBackgroundSize": 36,
                                    "iconBackgroundSizeUnit": "px",
                                    "iconBackgroundColor": {
                                        "color": "rgba(0, 105, 92, 1)",
                                        "type": "range",
                                        "rangeList": [
                                            {
                                                "from": 0,
                                                "to": 0,
                                                "color": "rgba(0, 105, 92, 1)"
                                            },
                                            {
                                                "from": 1,
                                                "color": "rgba(209, 39, 48, 1)",
                                                "to": null
                                            }
                                        ],
                                        "colorFunction": "var temperature = value;\nif (typeof temperature !== undefined) {\n  var percent = (temperature + 60)/120 * 100;\n  return tinycolor.mix('blue', 'red', percent).toHexString();\n}\nreturn 'blue';"
                                    },
                                    "valueFont": {
                                        "family": "Roboto",
                                        "size": 20,
                                        "sizeUnit": "px",
                                        "style": "normal",
                                        "weight": "500",
                                        "lineHeight": "24px"
                                    },
                                    "valueColor": {
                                        "type": "constant",
                                        "color": "rgba(0, 0, 0, 0.87)",
                                        "colorFunction": "var temperature = value;\nif (typeof temperature !== undefined) {\n  var percent = (temperature + 60)/120 * 100;\n  return tinycolor.mix('blue', 'red', percent).toHexString();\n}\nreturn 'blue';"
                                    },
                                    "showChevron": false
                                },
                                "title": "Alarm count",
                                "dropShadow": false,
                                "enableFullscreen": false,
                                "titleStyle": {
                                    "fontSize": "16px",
                                    "fontWeight": 400
                                },
                                "units": "",
                                "decimals": null,
                                "useDashboardTimewindow": true,
                                "showLegend": false,
                                "widgetStyle": {},
                                "actions": {},
                                "configMode": "advanced",
                                "displayTimewindow": true,
                                "margin": "0px",
                                "borderRadius": "4px",
                                "widgetCss": "",
                                "pageSize": 1024,
                                "noDataDisplayMessage": "",
                                "showTitleIcon": false,
                                "titleTooltip": "",
                                "titleFont": {
                                    "size": 12,
                                    "sizeUnit": "px",
                                    "family": null,
                                    "weight": null,
                                    "style": null,
                                    "lineHeight": "1"
                                },
                                "titleIcon": "",
                                "iconColor": "rgba(0, 0, 0, 0.87)",
                                "iconSize": "14px",
                                "timewindowStyle": {
                                    "showIcon": true,
                                    "iconSize": "14px",
                                    "icon": "query_builder",
                                    "iconPosition": "left",
                                    "font": {
                                        "size": 12,
                                        "sizeUnit": "px",
                                        "family": null,
                                        "weight": null,
                                        "style": null,
                                        "lineHeight": "1"
                                    },
                                    "color": null
                                },
                                "titleColor": "rgba(0, 0, 0, 0.54)"
                            },
                            "row": 0,
                            "col": 0,
                            "id": "cfad97c0-7046-a32d-0847-c5e80d8a8193"
                        },
                        "b80dfd80-d437-b60d-59bf-fa502f3e8027": {
                            "typeFullFqn": "system.entity_count",
                            "type": "latest",
                            "sizeX": 3.5,
                            "sizeY": 1.5,
                            "config": {
                                "datasources": [
                                    {
                                        "type": "entityCount",
                                        "name": "设备总数",
                                        "entityAliasId": "38aef70f-4d80-cfc6-7a1c-ad79edf5b9ab",
                                        "dataKeys": [
                                            {
                                                "name": "count",
                                                "type": "count",
                                                "label": "count",
                                                "settings": {},
                                                "_hash": 0.25773819438618184
                                            }
                                        ],
                                        "alarmFilterConfig": {
                                            "statusList": [
                                                "ACTIVE"
                                            ],
                                            "assignedToCurrentUser": false,
                                            "assigneeId": null
                                        }
                                    }
                                ],
                                "timewindow": {
                                    "displayValue": "",
                                    "selectedTab": 0,
                                    "realtime": {
                                        "realtimeType": 1,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "history": {
                                        "historyType": 0,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "fixedTimewindow": {
                                            "startTimeMs": 1714270399587,
                                            "endTimeMs": 1714356799587
                                        },
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "aggregation": {
                                        "type": "AVG",
                                        "limit": 25000
                                    }
                                },
                                "showTitle": false,
                                "backgroundColor": "rgb(255, 255, 255)",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "0px",
                                "settings": {
                                    "layout": "column",
                                    "autoScale": true,
                                    "showLabel": true,
                                    "label": "设备总数",
                                    "labelFont": {
                                        "family": "Roboto",
                                        "size": 10,
                                        "sizeUnit": "px",
                                        "style": "normal",
                                        "weight": "400",
                                        "lineHeight": "16px"
                                    },
                                    "labelColor": {
                                        "type": "constant",
                                        "color": "rgba(0, 0, 0, 0.54)",
                                        "colorFunction": "var temperature = value;\nif (typeof temperature !== undefined) {\n  var percent = (temperature + 60)/120 * 100;\n  return tinycolor.mix('blue', 'red', percent).toHexString();\n}\nreturn 'blue';"
                                    },
                                    "showIcon": true,
                                    "iconSize": 20,
                                    "iconSizeUnit": "px",
                                    "icon": "devices",
                                    "iconColor": {
                                        "type": "constant",
                                        "color": "rgba(255, 255, 255, 1)",
                                        "colorFunction": "var temperature = value;\nif (typeof temperature !== undefined) {\n  var percent = (temperature + 60)/120 * 100;\n  return tinycolor.mix('blue', 'red', percent).toHexString();\n}\nreturn 'blue';"
                                    },
                                    "showIconBackground": true,
                                    "iconBackgroundSize": 36,
                                    "iconBackgroundSizeUnit": "px",
                                    "iconBackgroundColor": {
                                        "type": "constant",
                                        "color": "rgb(241, 141, 23)",
                                        "colorFunction": "var temperature = value;\nif (typeof temperature !== undefined) {\n  var percent = (temperature + 60)/120 * 100;\n  return tinycolor.mix('blue', 'red', percent).toHexString();\n}\nreturn 'blue';",
                                        "rangeList": []
                                    },
                                    "valueFont": {
                                        "family": "Roboto",
                                        "size": 20,
                                        "sizeUnit": "px",
                                        "style": "normal",
                                        "weight": "500",
                                        "lineHeight": "24px"
                                    },
                                    "valueColor": {
                                        "type": "constant",
                                        "color": "rgba(0, 0, 0, 0.87)",
                                        "colorFunction": "var temperature = value;\nif (typeof temperature !== undefined) {\n  var percent = (temperature + 60)/120 * 100;\n  return tinycolor.mix('blue', 'red', percent).toHexString();\n}\nreturn 'blue';"
                                    },
                                    "showChevron": false
                                },
                                "title": "Entity count",
                                "dropShadow": false,
                                "enableFullscreen": false,
                                "titleStyle": {
                                    "fontSize": "16px",
                                    "fontWeight": 400
                                },
                                "units": "",
                                "decimals": null,
                                "useDashboardTimewindow": true,
                                "showLegend": false,
                                "widgetStyle": {},
                                "actions": {},
                                "configMode": "advanced",
                                "displayTimewindow": true,
                                "margin": "0px",
                                "borderRadius": "4px",
                                "widgetCss": "",
                                "pageSize": 1024,
                                "noDataDisplayMessage": "",
                                "showTitleIcon": false,
                                "titleTooltip": "",
                                "titleFont": {
                                    "size": 12,
                                    "sizeUnit": "px",
                                    "family": null,
                                    "weight": null,
                                    "style": null,
                                    "lineHeight": "1"
                                },
                                "titleIcon": "",
                                "iconColor": "rgba(0, 0, 0, 0.87)",
                                "iconSize": "14px",
                                "timewindowStyle": {
                                    "showIcon": true,
                                    "iconSize": "14px",
                                    "icon": "query_builder",
                                    "iconPosition": "left",
                                    "font": {
                                        "size": 12,
                                        "sizeUnit": "px",
                                        "family": null,
                                        "weight": null,
                                        "style": null,
                                        "lineHeight": "1"
                                    },
                                    "color": null
                                },
                                "titleColor": "rgba(0, 0, 0, 0.54)"
                            },
                            "row": 0,
                            "col": 0,
                            "id": "b80dfd80-d437-b60d-59bf-fa502f3e8027"
                        },
                        "04ebbd50-b063-ac02-3b53-21fb01aaa665": {
                            "typeFullFqn": "system.cards.entities_hierarchy",
                            "type": "latest",
                            "sizeX": 7.5,
                            "sizeY": 3.5,
                            "config": {
                                "timewindow": {
                                    "displayValue": "",
                                    "selectedTab": 0,
                                    "realtime": {
                                        "realtimeType": 1,
                                        "interval": 1000,
                                        "timewindowMs": 86400000,
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "history": {
                                        "historyType": 0,
                                        "interval": 1000,
                                        "timewindowMs": 60000,
                                        "fixedTimewindow": {
                                            "startTimeMs": 1714393291993,
                                            "endTimeMs": 1714479691993
                                        },
                                        "quickInterval": "CURRENT_DAY"
                                    },
                                    "aggregation": {
                                        "type": "NONE",
                                        "limit": 200
                                    }
                                },
                                "showTitle": true,
                                "backgroundColor": "rgb(255, 255, 255)",
                                "color": "rgba(0, 0, 0, 0.87)",
                                "padding": "4px",
                                "settings": {
                                    "nodeRelationQueryFunction": "var entity = nodeCtx.entity;\nvar query = {\n    parameters: {\n        rootId: entity.id.id,\n        rootType: entity.id.entityType,\n        direction: \"FROM\",\n        maxLevel: 1\n    },\n    filters: [{\n        relationType: \"Contains\",\n        entityTypes: []\n    }]\n};\nreturn query;\n\n/**\n\n// Function should return relations query object for current node used to fetch entity children.\n// Function can return 'default' string value. In this case default relations query will be used.\n\n// The following example code will construct simple relations query that will fetch relations of type 'Contains'\n// from the current entity.\n\nvar entity = nodeCtx.entity;\nvar query = {\n    parameters: {\n        rootId: entity.id.id,\n        rootType: entity.id.entityType,\n        direction: \"FROM\",\n        maxLevel: 1\n    },\n    filters: [{\n        relationType: \"Contains\",\n        entityTypes: []\n    }]\n};\nreturn query;\n\n**/\n",
                                    "nodeHasChildrenFunction": "/**\n\n// Function should return boolean value indicating whether current node has children (whether it can be expanded).\n\n// The following example code will restrict entities hierarchy expansion up to third level.\n\nreturn nodeCtx.level <= 2;\n\n// The next example code will restrict entities expansion according to the value of example 'nodeHasChildren' attribute.\n\nvar data = nodeCtx.data;\nif (data.hasOwnProperty('nodeHasChildren') && data['nodeHasChildren'] !== null) {\n    return data['nodeHasChildren'] === 'true';\n} else {\n    return true;\n}\n  \n**/\n ",
                                    "nodeOpenedFunction": "/**\n\n// Function should return boolean value indicating whether current node should be opened (expanded) when it first loaded.\n\n// The following example code will open by default nodes up to third level.\n\nreturn nodeCtx.level <= 2;\n\n**/\n ",
                                    "nodeDisabledFunction": "/**\n\n// Function should return boolean value indicating whether current node should be disabled (not selectable).\n\n// The following example code will disable current node according to the value of example 'nodeDisabled' attribute.\n\nvar data = nodeCtx.data;\nif (data.hasOwnProperty('nodeDisabled') && data['nodeDisabled'] !== null) {\n    return data['nodeDisabled'] === 'true';\n} else {\n    return false;\n}\n  \n**/\n",
                                    "nodeIconFunction": "/** \n\n// Function should return node icon info object.\n// Resulting object should contain either 'materialIcon' or 'iconUrl' property. \n// Where:\n    - 'materialIcon' - name of the material icon to be used from the Material Icons Library (https://material.io/tools/icons);\n    - 'iconUrl' - url of the external image to be used as node icon.\n// Function can return 'default' string value. In this case default icons according to entity type will be used.\n\n// The following example code shows how to use external image for devices which name starts with 'Test' and use \n// default icons for the rest of entities.\n\nvar entity = nodeCtx.entity;\nif (entity.id.entityType === 'DEVICE' && entity.name.startsWith('Test')) {\n    return {iconUrl: 'https://avatars1.githubusercontent.com/u/14793288?v=4&s=117'};\n} else {\n    return 'default';\n}\n \n**/",
                                    "nodeTextFunction": "/**\n\n// Function should return text (can be HTML code) for the current node.\n\n// The following example code will generate node text consisting of entity name and temperature if temperature value is present in entity attributes/timeseries.\n\nvar data =  nodeCtx.data;\nvar entity = nodeCtx.entity;\nvar text = entity.name;\nif (data.hasOwnProperty('temperature') && data['temperature'] !== null) {\n    text += \" <b>\"+ data['temperature'] +\" °C</b>\";\n}\nreturn text;\n\n**/",
                                    "nodesSortFunction": "/**\n\n// This function is used to sort nodes of the same level. Function should compare two nodes and return \n// integer value: \n//     - less than 0 - sort nodeCtx1 to an index lower than nodeCtx2\n//     - 0 - leave nodeCtx1 and nodeCtx2 unchanged with respect to each other\n//     - greater than 0 - sort nodeCtx2 to an index lower than nodeCtx1\n\n// The following example code will sort entities first by entity type in alphabetical order then\n// by entity name in alphabetical order.\n\nvar result = nodeCtx1.entity.id.entityType.localeCompare(nodeCtx2.entity.id.entityType);\nif (result === 0) {\n    result = nodeCtx1.entity.name.localeCompare(nodeCtx2.entity.name);\n}\nreturn result;\n  \n**/"
                                },
                                "title": "设备目录",
                                "dropShadow": false,
                                "enableFullscreen": true,
                                "titleStyle": {
                                    "fontSize": "16px",
                                    "fontWeight": 400,
                                    "padding": "5px 10px 5px 10px"
                                },
                                "useDashboardTimewindow": false,
                                "showLegend": false,
                                "datasources": [
                                    {
                                        "type": "entity",
                                        "name": "",
                                        "entityAliasId": "38aef70f-4d80-cfc6-7a1c-ad79edf5b9ab",
                                        "dataKeys": [
                                            {
                                                "name": "name",
                                                "type": "entityField",
                                                "label": "名称",
                                                "color": "#2196f3",
                                                "settings": {},
                                                "_hash": 0.9137146900799673
                                            }
                                        ],
                                        "alarmFilterConfig": {
                                            "statusList": [
                                                "ACTIVE"
                                            ]
                                        }
                                    }
                                ],
                                "widgetStyle": {},
                                "actions": {},
                                "displayTimewindow": true,
                                "showTitleIcon": false,
                                "titleTooltip": "",
                                "borderRadius": "4px",
                                "widgetCss": "",
                                "pageSize": 1024,
                                "noDataDisplayMessage": ""
                            },
                            "row": 0,
                            "col": 0,
                            "id": "04ebbd50-b063-ac02-3b53-21fb01aaa665"
                        }
                    },
                    "states": {
                        "default": {
                            "name": "鼓风机_01",
                            "root": true,
                            "layouts": {
                                "main": {
                                    "widgets": {
                                        "6a105a9f-63cb-338f-b52b-bbf32aa06926": {
                                            "sizeX": 12,
                                            "sizeY": 11,
                                            "row": 0,
                                            "col": 12
                                        },
                                        "01ae985f-4faa-d547-c1ba-e97916755d8f": {
                                            "sizeX": 8,
                                            "sizeY": 9,
                                            "row": 2,
                                            "col": 0
                                        },
                                        "cfad97c0-7046-a32d-0847-c5e80d8a8193": {
                                            "sizeX": 4,
                                            "sizeY": 2,
                                            "row": 0,
                                            "col": 4
                                        },
                                        "b80dfd80-d437-b60d-59bf-fa502f3e8027": {
                                            "sizeX": 4,
                                            "sizeY": 2,
                                            "row": 0,
                                            "col": 0
                                        },
                                        "04ebbd50-b063-ac02-3b53-21fb01aaa665": {
                                            "sizeX": 4,
                                            "sizeY": 11,
                                            "row": 0,
                                            "col": 8
                                        }
                                    },
                                    "gridSettings": {
                                        "backgroundColor": "#eeeeee",
                                        "columns": 24,
                                        "margin": 10,
                                        "outerMargin": true,
                                        "backgroundSizeMode": "100%"
                                    }
                                }
                            }
                        },
                        "current_details": {
                            "name": " ${entityName}:details",
                            "root": false,
                            "layouts": {
                                "main": {
                                    "widgets": {
                                        "bd1c5dc8-f131-2fa6-ee9d-daa45bf3b81b": {
                                            "sizeX": 6,
                                            "sizeY": 6,
                                            "row": 0,
                                            "col": 0
                                        },
                                        "9ca6aa90-677c-5ebe-39eb-d2530d546d3c": {
                                            "sizeX": 18,
                                            "sizeY": 6,
                                            "row": 0,
                                            "col": 6
                                        },
                                        "188cc3e9-0f3c-9b3f-4d10-9d15a5294726": {
                                            "sizeX": 13,
                                            "sizeY": 7,
                                            "row": 6,
                                            "col": 0
                                        },
                                        "2fab37b5-a7b8-a235-2942-63911512be03": {
                                            "sizeX": 11,
                                            "sizeY": 7,
                                            "row": 6,
                                            "col": 13
                                        }
                                    },
                                    "gridSettings": {
                                        "backgroundColor": "#eeeeee",
                                        "columns": 24,
                                        "margin": 10,
                                        "outerMargin": true,
                                        "backgroundSizeMode": "100%"
                                    }
                                }
                            }
                        }
                    },
                    "entityAliases": {
                        "38aef70f-4d80-cfc6-7a1c-ad79edf5b9ab": {
                            "id": "38aef70f-4d80-cfc6-7a1c-ad79edf5b9ab",
                            "alias": "电表",
                            "filter": {
                                "type": "deviceSearchQuery",
                                "resolveMultiple": true,
                                "rootStateEntity": false,
                                "stateEntityParamName": null,
                                "defaultStateEntity": null,
                                "rootEntity": {
                                    "entityType": "ASSET",
                                    "id": "23cacfb0-0519-11ef-8638-29a8cf47863a"
                                },
                                "direction": "FROM",
                                "maxLevel": 1,
                                "fetchLastLevelOnly": false,
                                "relationType": null,
                                "deviceTypes": [
                                    "物联网电表"
                                ]
                            }
                        },
                        "129a9367-471b-97bd-5f5f-7f8f3d30a73d": {
                            "id": "129a9367-471b-97bd-5f5f-7f8f3d30a73d",
                            "alias": "设备类型",
                            "filter": {
                                "type": "deviceType",
                                "resolveMultiple": true,
                                "deviceTypes": [
                                    "物联网电表"
                                ],
                                "deviceNameFilter": ""
                            }
                        }
                    },
                    "filters": {},
                    "timewindow": {
                        "displayValue": "",
                        "hideInterval": false,
                        "hideLastInterval": false,
                        "hideQuickInterval": false,
                        "hideAggregation": false,
                        "hideAggInterval": false,
                        "hideTimezone": false,
                        "selectedTab": 0,
                        "realtime": {
                            "realtimeType": 0,
                            "interval": 1000,
                            "timewindowMs": 60000,
                            "quickInterval": "CURRENT_DAY"
                        },
                        "history": {
                            "historyType": 0,
                            "interval": 1000,
                            "timewindowMs": 60000,
                            "fixedTimewindow": {
                                "startTimeMs": 1714193127270,
                                "endTimeMs": 1714279527270
                            },
                            "quickInterval": "CURRENT_DAY"
                        },
                        "aggregation": {
                            "type": "AVG",
                            "limit": 25000
                        }
                    },
                    "settings": {
                        "stateControllerId": "entity",
                        "showTitle": false,
                        "showDashboardsSelect": true,
                        "showEntitiesSelect": true,
                        "showDashboardTimewindow": true,
                        "showDashboardExport": true,
                        "toolbarAlwaysOpen": true
                    }
                },
                "externalId": null,
                "name": "鼓风机_01"
            }
            let info = {
                authCmd:{
                    cmdId: 0,
                    token: "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1ODA5MzI4QHFxLmNvbSIsInVzZXJJZCI6IjQ3ZDg3NDkwLWZjYTctMTFlZS04ODVlLTgzYWU1MDYyN2VmMSIsInNjb3BlcyI6WyJURU5BTlRfQURNSU4iXSwic2Vzc2lvbklkIjoiZWQ1M2M0MWItYTQ0Yi00Y2Q1LWFiMDItZGNmM2ZhNzQyYTFkIiwiaXNzIjoidGhpbmdzYm9hcmQuaW8iLCJpYXQiOjE3MTYzNDMyMzIsImV4cCI6Mzg2MzgyNjg3NywiZW5hYmxlZCI6dHJ1ZSwiaXNQdWJsaWMiOmZhbHNlLCJ0ZW5hbnRJZCI6IjQ3OGNjNTkwLWZjYTctMTFlZS04ODVlLTgzYWU1MDYyN2VmMSIsImN1c3RvbWVySWQiOiIxMzgxNDAwMC0xZGQyLTExYjItODA4MC04MDgwODA4MDgwODAifQ.SjQ_hxGFlEvI3POIas3qd27r9HdFsitSIfDhgIKJVhJFFtqCOGrXneQj6oeBRWKZ1L1LxV2CxZ7xbKLFssHI7Q"
                },
                cmds:[]
            }
            let params = {
                cmdId:Date.now(),
                latestCmd: {
                    keys:[]
                },
                query: {
                entityFields: [
                    {
                        "type": "ENTITY_FIELD",
                        "key": "name"
                    },
                    {
                        "type": "ENTITY_FIELD",
                        "key": "type"
                    },
                    {
                        "type": "ENTITY_FIELD",
                        "key": "label"
                    },
                    {
                        "type": "ENTITY_FIELD",
                        "key": "additionalInfo"
                    }
                ],
                entityFilter:{},
                latestValues:[],
                pageLink:{
                    "page": 0,
                    "pageSize": 16384,
                    "textSearch": null,
                    "dynamic": true
                }

            },
                type: "ENTITY_DATA"
            }
           
            for(let key in board.configuration.widgets){
                let widget = board.configuration.widgets[key]
                if(widget.typeFullFqn=="system.maps_v2.google_maps"){
                    let settings = widget.config.settings
                    let latKeyName,lngKeyName
                    params.query.pageLink.pageSize = settings.mapPageSize
                    latKeyName = settings.latKeyName
                    lngKeyName = settings.lngKeyName

                    for(let ekey in board.configuration.entityAliases){
                        if(ekey == widget.config.datasources[0].entityAliasId){
                            params.query.entityFilter = board.configuration.entityAliases[ekey].filter
                        }
                    }
                    
                    widget.config.datasources[0].dataKeys.map(dataKey=>{
                        if( ['attribute','timeseries'].indexOf(dataKey.type)!=-1){
                            params.latestCmd.keys.push({
                                type: dataKey.type.toUpperCase(), 
                                key: dataKey.name
                            })
                            params.query.latestValues.push({
                                type: dataKey.type.toUpperCase(), 
                                key: dataKey.name
                            })
                        }   
                    })

                }
              
            }
           
            info.cmds.push(params)

            ws.send(JSON.stringify(info))
            bus.$on('updatePoint',(msg)=>{

            })
        },
        handleChange(data, node, menu) {
            // console.log(data,node,menu)
            menu.label = data.fullName
        },
        checkMenu(menu) {
            menu.isActive = !menu.isActive
        },
        addMenu() {
            this.menus.push(
                {
                    id: 'menu-' + Date.now(),
                    moduleId: '',
                    label: '',
                    isActive: false,
                    showTree: false,
                    list:[],
                    columnData:{}
                }
            )
        },
        removeMenu(menu) {
            this.menus.splice(this.menus.findIndex(_menu => _menu.id == menu.id), 1)
        },
        // 功能列表
        fetchFeatureList() {
            if (!this.featureWebData.length) {
                getFeatureSelector({ type: 1 }).then(res => {
                    this.featureWebData = res.data.list
                })
            }
        },
        contexMenuEvent(menu) {

            const baseItems = [
                {
                    text: "删除",
                    keys: "",
                    func: () => {
                        this.removeMenu(menu)
                    },
                },
            ];
            this.menuContent = baseItems
        },

    },
}
</script>

<style>
.jnpf-menu {
    position: fixed;
    left: 300px;
    right: 280px;
    display: flex;
    justify-content: center;
    box-sizing: border-box;
    overflow: auto;
    overflow-anchor: none;
    bottom: 40px;
    z-index: 9999999999999;
}

.jnpf-menu-item {
    background: rgba(0, 0, 0, .85);
    box-shadow: inset 0px 0px 1px 0px;
    font-size: 14px;
    color: #fff;
    flex: 0 0 140px;
    margin: 0 5px;
    text-align: center;
    padding: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jnpf-menu-item {
    background: rgba(0, 0, 0, .85);
    box-shadow: inset 0px 0px 1px 0px;
    font-size: 14px;
    height: 24px;
    color: #fff;
    flex: 0 0 140px;
    margin: 0 5px;
    text-align: center;
    padding: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jnpf-menu-item.active {
    background: linear-gradient(180deg, rgba(87, 136, 255, 0.7) 0%, rgba(87, 136, 255, 0.5) 50%, #5788FF 100%) !important;
    /* color: #5788FF !important; */
}

.jnpf-menu-item .eye {
    width: 24px;
    height: 100%;
    margin-left: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}
</style>
